<!DOCTYPE html>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	    <meta name="format-detection" content="telephone=no">
	    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
	    <link href="../../../css/bootstrap.css" rel="stylesheet" />
	    <link href="../../../css/cover.css" rel="stylesheet" />
	    <link href="../../../css/font-awesome.min.css" rel="stylesheet" />
	    <title>荆州千网汇信息科技有限公司</title>
	    <script src="../../../js/jquery-2.2.3.min.js"></script>
	    <script src="../../../js/jquery.flexslider-min.js"></script>
	    <script src="../../../js/rem.js"></script>
	    <script src="../../../js/itnetcao.js"></script>
	    <link href="../../../js/layui/css/layui.css" rel="stylesheet" />
	    <link href="../../../js/donghua/animsition.min.css" rel="stylesheet" />
	    <script src="../../../js/donghua/animsition.min.js"></script>
	    <link rel="stylesheet" href="../../../css/minirefresh.css" />
	    <link rel="stylesheet" href="../../../css/common.css" />
	    <script type="text/javascript" src="../../../js/minirefresh.js"></script>
	    <script type="text/javascript" src="../../../js/common.js"></script>
	    <script type="text/javascript" src="../../../js/layer.js"></script>
		<style type="text/css">
		*{
			margin: 0px;
			padding: 0px;
			font-family:"微软雅黑"
		}
		</style>
	</head>
	<body>
		<div class="page_top01 relative">
            <h3 class="text-center">支付宝信息</h3>
            <a href="javascript:;" class="animsition-link" data-animsition-out-class="fade-out-right" data-animsition-out-duration="500" onclick="history.go(-1)">
                <img src="../../../images/icon_left.png" class="img-responsive reture_img" /></a>
        </div>
		<div class="layui-fluid layui-form layui-form-pane">
			<div class="layui-row layui-col-space15">
				
				<div class="layui-col-xs12">
					<div class="layui-form-item">
					    <label class="layui-form-label">支付宝账号</label>
					    <div class="layui-input-block">
							<input type="text" name="proKey" placeholder="请输入支付宝账号" class="custMyInput layui-input">
					    </div>
					</div>
				</div>
				
				<div class="layui-col-xs12">
					<div class="layui-form-item">
					    <label class="layui-form-label">二维码</label>
					    <div class="layui-input-block">
							<button onclick="document.getElementById('file').click();" class="layui-btn layui-btn-normal loadFile" style='width:100%;'>请选择文件</button>
							<input type='file' id='file' name="proValue" style='display:none;'/>
					    </div>
					</div>
				</div>
				<div class="layui-col-xs12" style='text-align:center;'>
					预览
				</div>
				<div class="layui-col-xs12" align='center'>
					<img  class='MyQrCode' style='width:200px;height:200px;'/>
				</div>
				<div class="layui-col-xs12" style='margin-top:5%;'>
					<button class='layui-btn layui-btn-warm saveOrUpdate' style='width:100%;'>保存</button>
				</div>
			</div>
		</div>
	
<script type='text/javascript'>
var userId = jQuery.parseJSON(localStorage.getItem("miningmachine_user")).userId;
var url = localStorage.getItem("url") + "/user/controller/UserPropertyFindByIdAndTypeAPP.do";
var data = "userId=" + userId + "&propertyType=1";
var dataId = null;
itcao.itGetAjaxBigData(url, data).done(function(result) {
	var json = jQuery.parseJSON(result);
	if(json.state == true) {
		var j = json.bean;
		dataId = j.proId
		$("input[name='proKey']").val(j.proKey);
		$("input[name='proValue']").attr("src", j.proValue);
		// 预览加载
		$(".MyQrCode").attr("src", localStorage.getItem("url") + "/" + j.proValue);
	}
})
$(function() {
	$("#file").change(function() {
		try{
			$(".MyQrCode").attr("src", window.URL.createObjectURL($("#file").get(0).files.item(0)));
		}catch(e){}
	})
	
	$(".saveOrUpdate").click(function() {
		if($("input[name='proKey']").val().trim().length == 0) {
			alert("您必须输入支付宝账号.");
			return;
		}
		if($("input[name='proValue']").val().trim().length == 0) {
			alert("文件不允许为空.");
			return;
		}
		var formData = new FormData();
		formData.append('file', $('#file')[0].files[0]);
		formData.append('proKey', $("input[name='proKey']").val());
		formData.append('proType', "1");
		formData.append('proUserId', userId);
		var url = localStorage.getItem("url")
		if(dataId == null) {
			url = url + "/user/controller/UserPropertySaveAPP.do";
		}else {
			url = url + "/user/controller/UpdateUserPropertyAPP.do";
			formData.append("proId", dataId);
		}
		
		itcao.itcaoGetImageAjaxData(url, formData).done(function(result) {
			var json = jQuery.parseJSON(result);
			if(json.state == true){
				alert("保存或修改成功.");
			}else {
				alert("修改失败:" + json.value);
			}
		})
	})
	
})
</script>
</body>
</html>
